package com.dream.model.app;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.dream.model.base.AppUserModelBase;

@Entity
@Table(name="t_app_image")
public class AppImage extends AppUserModelBase implements Serializable {
	

	/**
	 * 
	 */
	private static final long serialVersionUID = -3512816532893363834L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	//@GeneratedValue(strategy = GenerationType.SEQUENCE,generator="app_image_seq")
	//@SequenceGenerator(name="app_image_seq",sequenceName="APP_IMAGE_SEQ")
	private Long id;
	
	@Column(name="name")
	private String name;
	
	@Column(name="uri")
	private String uri;
	
	@Column(name="thumbnail_uri")
	private String thumbnailUri;
	
	@Column(name="image_type")
	private String imageType;
	
	@Column(name="status")
	@Enumerated(EnumType.STRING)
	private ImageStatus status;
	
	public ImageStatus getStatus() {
		return status;
	}

	public void setStatus(ImageStatus status) {
		this.status = status;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AppImage other = (AppImage) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUri() {
		return uri;
	}

	public void setUri(String uri) {
		this.uri = uri;
	}

	public String getThumbnailUri() {
		return thumbnailUri;
	}

	public void setThumbnailUri(String thumbnailUri) {
		this.thumbnailUri = thumbnailUri;
	}

	public String getImageType() {
		return imageType;
	}

	public void setImageType(String imageType) {
		this.imageType = imageType;
	}

	public String getThumbImgFullPath(){
		
		return new StringBuilder(thumbnailUri).append(id).append(".").append(imageType).toString();
	}
	
	public String getEntireImgFullPath(){
		
		return new StringBuilder(uri).append(id).append(".").append(imageType).toString();
	}
	
	public static enum ImageStatus {normal,delete,exception} 
	
}
